<?php
include('inc_head.php');
$tag=$wu->request_string('tag');
if(!$tag) 		die('参数有误');
$id=$wu->request_int('id');
if($wu->request_string('act')=='del' && $id){
	$db->delete('tgeneralcatalog',"ID=$id");
	$wu->redirect('删除成功','catalog_list.php?tag='.$tag);
}
?>
<div style="margin:5px;"><a href='catalog_edit.php?tag=<?php echo $tag; ?>' class="btn btn-info">新增</a></div>
<table class="table table-hover table-bordered">
    <thead>
        <tr><th>顺序</th><th>名称</th><th>操作</th></tr>
    </thead>
    <tbody>
    <?php
		$rs=$db->fetch_all("select * from tgeneralcatalog where ParentID=0 and ExTags='$tag'");
		if($rs){
			foreach($rs as $row){
				echo '<tr><td>'.$row['Ordinal'].'</td><td>'.$row['Name'].'</td><td><a href="catalog_edit.php?tag='.$row['ExTags'].'&id='.$row['ID'].'">编辑</a> <a href="?act=del&tag='.$tag.'&id='.$row['ID'].'">删除</a> <a href="catalog_edit.php?tag='.$row['ExTags'].'&pid='.$row['ID'].'">新增</a></td></tr>';
				$rs2=$db->fetch_all("select * from tgeneralcatalog where ParentID=".$row['ID']);
				if($rs2){
					foreach($rs2 as $row2){
						echo '<tr><td>'.$row2['Ordinal'].'</td><td>--'.$row2['Name'].'</td><td><a href="catalog_edit.php?tag='.$row2['ExTags'].'&id='.$row2['ID'].'">编辑</a> <a href="?act=del&tag='.$tag.'&id='.$row2['ID'].'">删除</a> <a href="catalog_edit.php?tag='.$row2['ExTags'].'&pid='.$row2['ID'].'">新增</a></td></tr>';
					}
				}
			}
		}
	?>
    </tbody>
</table>
<?php
	include('inc_foot.php');
?>